HAL OPAMP types migration ¶
This section provides information about the HAL OPAMP types migration.
HAL OPAMP callback ID type definition ¶
|
HAL1 |
HAL2 |
|---|---|
typedef enum
{
HAL_OPAMP_ALL_CB_ID;
HAL_OPAMP_MSP_DEINIT_CB_ID;
HAL_OPAMP_MSP_INIT_CB_ID;
} HAL_OPAMP_CallbackIDTypeDef;
|
Removed . Note The callback registration in HAL2 is removed since there’s no specific callback for OPAMP. |
Related concepts:
HAL OPAMP state type definition ¶
|
HAL1 |
HAL2 |
|---|---|
typedef enum
{
HAL_OPAMP_STATE_BUSY,
HAL_OPAMP_STATE_BUSYLOCKED,
HAL_OPAMP_STATE_CALIBBUSY,
HAL_OPAMP_STATE_READY,
HAL_OPAMP_STATE_RESET
} HAL_OPAMP_StateTypeDef;
|
typedef enum
{
HAL_OPAMP_STATE_RESET
HAL_OPAMP_STATE_IDLE
HAL_OPAMP_STATE_CALIB
HAL_OPAMP_STATE_ACTIVE
} hal_opamp_state_t;
|
Related concepts:
HAL OPAMP handle type definition ¶
|
HAL1 |
HAL2 |
|---|---|
OPAMP_HandleTypeDef;
|
hal_opamp_handle_t;
|
Related concepts:
HAL OPAMP initialization type definition ¶
|
HAL1 |
HAL2 |
|---|---|
typedef OPAMP_InitTypeDef;
|
typedef hal_comp_config_t
typedef hal_opamp_config_input_connection_t
typedef hal_opamp_trimming_offset_pair_t;
|
typedef struct
{
uint32_t PowerSupplyRange;
uint32_t PowerMode;
uint32_t Mode;
uint32_t InvertingInput;
uint32_t NonInvertingInput;
uint32_t PgaGain;
uint32_t UserTrimming;
// Example HAL1 :
HAL_OPAMP_Init(OPAMP1);
// UserTrimming set to OPAMP_TRIMMING_FACTORY;
HAL_OPAMP_SelfCalibrate(OPAMP1);
// UserTrimming set to OPAMP_TRIMMING_USER;
// In HAL1 there is a specific parameter in the configuration structure
// regarding the calibration process in normal and low power mode :
// Offset trimming value (PMOS) in Normal Mode
uint32_t TrimmingValueP;
// Offset trimming value (PMOS) in lowpower mode
uint32_t TrimmingValuePLowPower;
// Offset trimming value (NMOS) in Normal Mode
uint32_t TrimmingValueN;
// Offset trimming value (NMOS) in lowpower mode
uint32_t TrimmingValueNLowPower;
} OPAMP_InitTypeDef;
|
typedef struct
{
hal_opamp_power_supply_range_t power_supply_range;
hal_opamp_power_mode_t power_mode;
hal_opamp_speed_mode_t speed_mode;
hal_opamp_config_mode_t configuration_mode;
} hal_opamp_config_t;
typedef struct
{
hal_opamp_inverting_input_t inverting_input;
hal_opamp_non_inverting_input_t non_inverting_input;
} hal_opamp_config_input_connection_t;
/*unitary function to Set/Get Gain*/
hal_status_t HAL_OPAMP_SetGain(const hal_opamp_handle_t *hopamp, hal_opamp_pga_gain_t gain);
hal_opamp_pga_gain_t HAL_OPAMP_GetGain(const hal_opamp_handle_t *hopamp);
/* In HAL2, the UserTrimming parameter is no longer present in the configuration structure
Instead : trimming is set to factory mode by default, and when calling HAL_OPAMP_Calibrate(),
trimming automatically switches to user mode.*/
/*unitary function to Get user trimming configuration*/
hal_opamp_trimming_mode_t HAL_OPAMP_GetTrimmingMode(const hal_opamp_handle_t *hopamp)
// Example HAL2 :
uint32_t UserTrimming;
HAL_OPAMP_Init(opamp1);
UserTrimming = HAL_OPAMP_GetTrimmingMode(OPAMP1) ;
// UserTrimming set to HAL_OPAMP_TRIMMING_MODE_FACTORY;
HAL_OPAMP_Calibrate(opamp1);
UserTrimming = HAL_OPAMP_GetTrimmingMode(OPAMP1) ;
// UserTrimming set to HAL_OPAMP_TRIMMING_MODE_USER;
// In HAL2, the calibration mode (normal or low power) is now provided
// as a parameter to the dedicated calibration function.
// Trimming values (PMOS/NMOS) for both normal and low power modes
// can be configured using the structure hal_opamp_trimming_offset_pair_t
// after calling the function HAL_OPAMP_SetConfigTrimming().
typedef struct
{
// Offset trimming value (PMOS) in Normal / LOW POWER Mode
uint32_t trim_offset_p;
// Offset trimming value (NMOS) in Normal / LOW POWER Mode
uint32_t trim_offset_n;
} hal_opamp_trimming_offset_pair_t;
// The trimming values can be set using ddedicated function :
HAL_OPAMP_SetConfigTrimming(const hal_opamp_handle_t *hopamp,
hal_opamp_trimming_offset_pair_t *p_config,
hal_opamp_power_mode_t power_mode)
// And also a dedicated function is available to get the trimming configuration :
HAL_OPAMP_GetConfigTrimming(const hal_opamp_handle_t *hopamp,
hal_opamp_trimming_offset_pair_t *p_config,
hal_opamp_power_mode_t power_mode)
|
Related concepts: